refactor(tui): tidy imports, style calls, and widget construction#21
Merged
veryCrunchy merged 3 commits intomainfrom Jan 12, 2026
Merged
refactor(tui): tidy imports, style calls, and widget construction#21veryCrunchy merged 3 commits intomainfrom
veryCrunchy merged 3 commits intomainfrom
Conversation
- reorder and consolidate ratatui imports to remove redundant Frame import - simplify Span::styled calls by collapsing multi-line constructions into single-line expressions for readability - chain Paragraph::new().block(...) calls instead of nested block() formatting to make widget construction more concise - change timeout validation to reject zero explicitly (timeout == 0) ensuring the error message matches the intended minimum of 1 second These changes improve code clarity and consistency in the TUI codebase and fix a subtle validation condition.
There was a problem hiding this comment.
Pull request overview
This PR refactors TUI code to improve consistency and clarity without introducing any functional changes. The changes include reorganizing imports, simplifying formatting, and fixing a validation condition to be more explicit.
Changes:
- Changed timeout validation from
timeout < 1totimeout == 0for clarity and consistency with similar validation functions - Reordered ratatui imports to place Frame first, matching the pattern in other TUI files
- Simplified Span::styled calls from multi-line to single-line for simple string literals
- Refactored Paragraph widget construction to use method chaining consistent with other UI modules
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/service/src/validation.rs | Updated timeout validation to use explicit zero check (timeout == 0), improving clarity and consistency with the interval validation function |
| apps/service/src/tui/ui/network.rs | Reorganized imports, simplified Span::styled formatting, and refactored Paragraph construction to match patterns used in other TUI modules |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Update TUI code to use Rust's let-chains and inline formatting in several
places for clarity and conciseness.
- Simplify string interpolation in result_detail popup:
use format!("({region})") and format!("Location: {location}") instead
of explicit clones and older formatting patterns.
- Replace nested if-let blocks with let-chain conditions in edit event
handling, cursor movement, save flow, and monitor adjustments. This
removes redundant nesting and braces, making the control flow more
readable.
- Apply let-chains to repeated branches that adjust monitor fields
(interval, timeout, enabled) and to moving the text cursor / validating
and saving monitors.
These changes improve readability and reduce boilerplate without changing
behavior.
Adjust multiple source files to correct the new if-let chaining/formatting
to comply with clearer block scoping and avoid confusing indentation.
Key changes:
- Expand chained if-let conditions into explicit blocks in several UI
handlers (tui/events/keyboard.rs, mouse.rs) so the guarded code is
wrapped in a clear { ... } block. This fixes formatting and makes the
control flow easier to read and maintain.
- Apply the same block-style for conditional checks in orchestrator's
P2P sharing path (orchestrator/mod.rs) to ensure the error-logging
branch is executed within a proper block.
- Use explicit block scoping for location cache initialisation
(location.rs) to avoid ambiguous line breaks when matching nested
conditions.
Why:
- The changes improve readability and maintainability by removing
fragile single-line if-let chaining and ensuring consistent block
structure for conditional logic across the codebase.
- They also reduce the risk of logic being accidentally excluded due to
formatting or line-break changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
into single-line expressions for readability
formatting to make widget construction more concise
ensuring the error message matches the intended minimum of 1 second
These changes improve code clarity and consistency in the TUI codebase
and fix a subtle validation condition.